package com.ruoyi.machine.advanced.status.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.machine.advanced.status.domain.Status;
import com.ruoyi.machine.advanced.status.domain.StatusCond;
import com.ruoyi.machine.advanced.status.service.IStatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备状态信息
 * 控制层
 */
@RestController
@RequestMapping("/machine/status")
@Api(value = "设备状态信息模块", tags = "设备状态信息接口")
public class StatusController extends BaseController{

    @Autowired
    private IStatusService statusService;

    /**
     * 获取设备状态信息列表
     * @param status
     * @return
     */
    @ApiOperation(value = "获取设备状态列表",notes = "查询所有设设备状态信息")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody StatusCond status) {

        startPage();

        List<Status> statusList = statusService.selectStatusList(status);

        return getDataTable(statusList);
    }

    /**
     * 导出设备状态信息
     * @param status
     * @return
     */
    @PostMapping("/export")
    public AjaxResult export(@RequestBody StatusCond status) {

        List<Status> statusList = statusService.selectStatusList(status);

        ExcelUtil<Status> util = new ExcelUtil<>(Status.class);

        return util.exportExcel(statusList, "附属状态信息数据");
    }

}
